package com.example.mapperapi.mapperMethod;

import cn.hutool.core.date.LocalDateTimeUtil;

import java.time.LocalDateTime;
import java.util.function.Function;

/**
 * 时间戳映射器方法(示例)
 *
 * @author 徐鑫
 * @date 2023/03/26
 */
public final class TimeStampMapperMethod implements Function<Object, Object> {

    @Override
    public Object apply(Object o) {
        LocalDateTime localDateTime = null;
        if (o instanceof String) {
            long along = Long.parseLong((String) o);
            localDateTime = LocalDateTimeUtil.of((along));
        }
        if (o instanceof Long) {
            localDateTime = LocalDateTimeUtil.of((Long) o);
        }
        return localDateTime;
    }
}
